package com.online.studyonline.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//我们需要写一个配置类，添加如下的方法
@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {
    //配置静态资源路径
    @Value("${video_path}")
    private String filePath;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("file:///"+filePath);
    }
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        // 配置静态资源处理器，暴露视频文件
//        registry.addResourceHandler("/video/**")
//                .addResourceLocations("file:///" + videoPath);
//    }
}